package com.dctobacco.dongchengtobaccoandroid.ui;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;

import com.dctobacco.dongchengtobaccoandroid.R;
import com.dctobacco.dongchengtobaccoandroid.fragment.MyFragmentController;


import java.util.ArrayList;
import java.util.List;


public class MainActivity extends FragmentActivity implements
        MenuFragment.MenuItemCheckedChangeListener,ManagerFragment.OnManagerFragmentSelectedListener,
        NewsCenterFragment.OnNewsCenterFragmentSelectedListener,WorkReportFragment.OnWorkReportFragmentSelectedListener,
        UserCenterFragment.OnUserCenterFragmentSelectedListener{

    private MyFragmentController fragmentController;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        initFragment();
        initData();

    }



    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);

    }

    /**
     * 初始化控件
     */
    private void initView() {


    }

    /**
     * 初始化Fragment
     */
    private void initFragment() {
        List<Fragment> fragments= new ArrayList<>();
//      任务管理
        ManagerFragment managerFragment = new ManagerFragment();
        fragments.add(managerFragment);
//      实时资讯
        NewsCenterFragment newsCenterFragment = new NewsCenterFragment();
        fragments.add(newsCenterFragment);
//      工作报表
        WorkReportFragment workReportFragment = new WorkReportFragment();
        fragments.add(workReportFragment);
//      个人中心
        UserCenterFragment userCenterFragment = new UserCenterFragment();
        fragments.add(userCenterFragment);
        fragmentController = new MyFragmentController(this,R.id.frame_content,fragments);
//      默认显示第一条
        fragmentController.showFragment(0);
    }

    /**
     * 初始化数据
     */
    private void initData() {
    }

    /**
     * @param checkedId
     * 响应左侧按钮点击事件
     */
    @Override
    public void onCheckedChanged(int checkedId) {

        switch (checkedId){
            case R.id.manager_radiobtn:
                fragmentController.showFragment(0);
                break;
            case R.id.newscenter_radiobtn:
                fragmentController.showFragment(1);
                break;
            case R.id.workreport_radiobtn:
                fragmentController.showFragment(2);
                break;
            case R.id.usercenter_radiobtn:
                fragmentController.showFragment(3);
                break;

        }

    }

    /**
     *功能描述：扫描二维码
     */
    @Override
    public void qrCodeScan() {

    }

    /**
     * 功能描述：跳转到用户中心
     */
    @Override
    public void jumpUserInfoPager() {

    }

    @Override
    public void onManagerArticleSelected(int position) {

    }

    @Override
    public void onNewsCenterFragmentArticleSelected(int position) {

    }

    @Override
    public void onWorkReportFragmentArticleSelected(int position) {

    }

    @Override
    public void onUserCenterFragmentArticleSelected(int position) {

    }
}
